{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加角色</h5>
                </div>
                <div class="ibox-content">
                    <form class="layui-form layui-form-pane" id="roleAdd">
                        <div class="layui-form-item">
                            <label class="layui-form-label">角色名称</label>
                            <div class="layui-input-inline">
                                <input id="title" type="text" class="layui-input" autocomplete="off" name="title" >
                            </div>

                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">状&emsp;&emsp;态</label>
                            <div class="layui-input-inline">
                                <input type="radio" name='status' value="1" checked="checked" title="开启"/>&nbsp;&nbsp;
                                <input type="radio" name='status' value="0" title="关闭"/>
                            </div>

                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="layui-form-item">
                            <div class="layui-input-inline">
                                <button class="btn btn-primary" lay-submit lay-filter="role"><i class="fa fa-save"></i> 保存</button>&emsp;&emsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
var form = layui.form;

    $(function(){
        form.on('submit(role)',function (data) {
            var data = data.field;
            if( !data.title){
                layer.msg('请输入角色名称',{icon:2,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }
            $.post("{:url('roleAdd')}",data,function (result) {
                if(result.code==1){
                    layer.msg(result.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                        window.location.href="{:url('role/index')}";
                    });
                }else{
                    layer.msg(result.msg, {icon: 5,time:1500,shade: 0.1});
                    return false;
                }
            });

            return false;
        });
    });


</script>
</body>
</html>
